/*
Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent.

A mapping of digit to letters (just like on the telephone buttons) is given below.


Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].

*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <sstream>
#include <unordered_set>
#include <unordered_map>
#include "print.h"
using namespace std;

/**
* Definition for binary tree*/
typedef __int32 uint32_t;


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}

void testForIntToString()
{
	int a = 10;
	stringstream ss;
	ss << a;
	string str = ss.str();
	cout << str << endl;

	string str1 = to_string(a);

}
/*

alpMap[1] = "A";
alpMap[2] = "B";
alpMap[3] = "C";
alpMap[4] = "D";
alpMap[5] = "E";
alpMap[6] = "F";
alpMap[7] = "G";
alpMap[8] = "H";
alpMap[9] = "I";
alpMap[10] = "J";
alpMap[11] = "K";
alpMap[12] = "L";
alpMap[13] = "M";
alpMap[14] = "N";
alpMap[15] = "O";
alpMap[16] = "P";
alpMap[17] = "Q";
alpMap[18] = "R";
alpMap[19] = "S";
alpMap[20] = "T";
alpMap[21] = "U";
alpMap[22] = "V";
alpMap[23] = "W";
alpMap[24] = "X";
alpMap[25] = "Y";
alpMap[26] = "Z";
*/

class Solution {
private:
	map<int, string> digitalTable;
	vector<string> vecStr;


public:
	void dfs(int dep, int maxDep, string &digits, string result)
	{
	
		/*
		if (dep == maxDep)
40         {
41             ret.push_back(ans);
42             return;
43         }
44         
45         for(int i = 0; i < dict[s[dep]].size(); i++)
46             dfs(dep + 1, maxDep, s, ans + dict[s[dep]][i]);
		*/
		if (dep == maxDep)
		{
			vecStr.push_back(result);
			return;
		}
		for (int i = 0; i < digitalTable[digits[dep]-'0'].size(); i++)
		{
			dfs(dep + 1, maxDep, digits, result + digitalTable[digits[dep] - '0'].substr(i,1));

		}
	
	}
	vector<string> letterCombinations(string digits) {
		//map<int, string> digitalTable;

		digitalTable[2] = "abc";
		digitalTable[3] = "def";
		digitalTable[4] = "ghi";
		digitalTable[5] = "jkl";
		digitalTable[6] = "mno";
		digitalTable[7] = "pqrs";
		digitalTable[8] = "tuv";
		digitalTable[9] = "wxyz";

		vecStr.clear();
		int size = digits.size();

		if (size == 0)
			return vecStr;
		//if (size == 0)return vecStr;
		dfs(0,size,digits,"");
		return vecStr;




	}
};



int main(int argc, char* argv[])
{

	string str1;


	for (int i = 1; i < argc; i++){


		cout << argv[i] << endl;
		str1 = argv[i];
	}


	string str2 ="23";
	char a = str2[2];
	char one = '1';
	int num = str2[1] - '0';

	string str3 = str2 + str2[1];
	cout << num << endl;

	Solution s;
	vector<string> vecStr;
	vecStr = s.letterCombinations(str1);

	//stackTree.push(p->left);
	//stackTree.push(p->right);

	//ListNode *headA = new ListNode(1);
	//ListNode *pa1 = new ListNode(2);
	//ListNode *pa2 = new ListNode(3);
	//headA->next = pa1;
	//pa1->next = pa2;

	//ListNode *headB = new ListNode(4);
	//ListNode *pa1 = new ListNode(2);
	//ListNode *pa2 = new ListNode(3);
	//headA->next = pa1;
	//pa1->next = pa2;

	





	system("pause");
	return 0;
}